package cn.tqfeiyang.smartadmin.commons.application;

import cn.hutool.cache.Cache;
import cn.tqfeiyang.smartadmin.commons.toolbox.CacheUtils;
import cn.tqfeiyang.smartadmin.commons.toolbox.EnvironmentUtils;
import cn.tqfeiyang.smartadmin.commons.toolbox.PasswordUtils;
import org.apache.ibatis.annotations.Mapper;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Import;

@SpringBootApplication
@EnableCaching
@ComponentScan(basePackages = "cn.tqfeiyang.smartadmin")
@MapperScan(basePackages = "cn.tqfeiyang.smartadmin", annotationClass = Mapper.class)
@Import(cn.hutool.extra.spring.SpringUtil.class)
public class BoostrapApplication implements CommandLineRunner {

    public static void main(String[] args) {
        SpringApplication.run(BoostrapApplication.class, args);
    }

    @Override
    public void run(String... args) throws Exception {
        if (!EnvironmentUtils.isDevelopment()) {
            return;
        }

//        String plaintext = "123456";
//        String encrypted = PasswordUtils.encrypt(plaintext);
//        System.out.println("明文：" + plaintext);
//        System.out.println("加密后：" + encrypted);
//
//
//        Cache<String, String> cache = CacheUtils.newCache();
//        cache.put("name", "张三");
//        cache.put("phone", "123345");
    }
}
